
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.Timer;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Henri
 */
public class strelaPonorka extends JLabel implements ActionListener {

    Timer t;
    Panel kde;
    Rectangle rectangle;
    public strelaPonorka(int x, int y, Panel kde) {
        t = new Timer(100, this);
        t.start();
        this.kde = kde;
        setBounds(x, y, 30, 30);
        rectangle = new Rectangle(x, y, 5, 9);
  //      ImageIcon torpedo = new ImageIcon("img/torpedo.png");
        this.setIcon(new javax.swing.ImageIcon(getClass().getResource("img/torpedo.png")));
 //       this.setIcon(torpedo);
        setFocusable(false);
    }

    protected void pohybH() {
        int zmena = getY() - 6;
        setLocation(getX(), zmena);
        this.rectangle.setLocation(this.getLocation());
    }

    protected void zmizni() {
        kde.remove(this);
        this.rectangle.setLocation(800, 0);
        t.stop();

    }

    public void actionPerformed(ActionEvent e) {
        pohybH();
        if (getY() < 72) {
            zmizni();
        }

    }
}
